<%@page import="com.situ.entity.Student"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%
		ArrayList<Student> list = (ArrayList<Student>)request.getAttribute("list");
	%>
	<a href="/JavaWeb/student_add.jsp">添加</a>
	<table border="1" cellspacing="0" width="400px">
		<tr>
			<td>ID</td>
			<td>名字</td>
			<td>年龄</td>
			<td>性别</td>
			<td>删除</td>
		</tr>
		<%
			for (Student student : list) {
		%>
				<tr>
					<td><%=student.getId()%></td>
					<td><%=student.getName()%></td>
					<td><%=student.getAge()%></td>
					<td><%=student.getGender()%></td>
					<%-- <td><a href="/JavaWeb/deleteStudent?id=<%=student.getId()%>">删除</a></td> --%>
					<td><a onclick="deleteById(<%=student.getId()%>)" href="javascript:void(0)">删除</a></td>
				</tr>
		<% 
			}
		
		%>
		
		
	</table>
	<script type="text/javascript">
		function deleteById(id) {
			var isDelete = confirm('您确认要删除么？');
			if (isDelete) {
				// 在js里面单引号和双引号都可以
				location.href = '/JavaWeb/student?method=deleteById&id=' + id;
			}
		}
	</script>
	
</body>
</html>